/* 
 * Copyright (C) 2012 Martin Řehánek <rehan at mzk.cz>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

goog.provide('kramerius.audio.ui.playlist.PlaylistMenu');

goog.require('goog.ui.PopupMenu');
goog.require('goog.ui.Control');
//TODO: remove
goog.require('goog.ui.MenuItem');

/**
 * @constructor 
 * @param {Element} container Element containing this component.
 * @param {kramerius.audio.Controller} controller Controller of the audio player.
 */
kramerius.audio.ui.playlist.PlaylistMenu = function(container, controller){
    kramerius.audio.ui.PlayerComponent.call(this, container, controller);
    this.controller_.setPlaylistMenu(this);
    this.menu_ = this.initMenu_();
    this.trackContainers_ = [];
};
goog.inherits(kramerius.audio.ui.playlist.PlaylistMenu, kramerius.audio.ui.PlayerComponent);


kramerius.audio.ui.playlist.PlaylistMenu.prototype.initMenu_ = function(){
    var menu = new goog.ui.PopupMenu();
    //var test1 = new goog.ui.Control("c1");
    //menu.addChild(test1,true);
    menu.render(this.container_);
    
    //console.log("container: " + this.container_);
    //    menu.addItem(new goog.ui.MenuItem('One'));
    //    menu.addItem(new goog.ui.MenuItem('Two'));
    //    menu.addItem(new goog.ui.MenuItem('Three'));
    //    menu.addItem(new goog.ui.MenuItem('Four'));
    //    menu.addItem(new goog.ui.MenuItem('Five'));
    //    menu.addItem(new goog.ui.MenuItem('Super long item'));
    //menu.decorate(this.container_);
    //    menu.attach(this.container_,
    ////        goog.positioning.Corner.BOTTOM_LEFT,
    //        //goog.positioning.Corner.BOTTOM_LEFT,
    //        goog.positioning.Corner.TOP_LEFT,
    //        
    //        //goog.positioning.Corner.TOP_LEFT
    //        goog.positioning.Corner.BOTTOM_LEFT
    //    );
        
    menu.attach(this.container_);
    return menu;
    
}


//kramerius.audio.ui.playlist.PlaylistMenu.prototype.addTrackContainer = function(trackContainer){
//    //TODO: pridat do trackContainers_
//    this.menu_.addChild(trackContainer, true);
//}

kramerius.audio.ui.playlist.PlaylistMenu.prototype.addTrackComponent = function(trackContainer){
    //TODO: pridat do trackContainers_
    this.menu_.addChild(trackComponent.getContainer(), true);
}
